#pragma once
#include <memory>
#include <boost/signals2.hpp>
#include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/Image.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <nice2d/sfmlmessage.h>
#include <nice2d/object.h>

class Application : public Object
{
    static std::shared_ptr<Application> instance;
    DECLARE_OBJECT(Application)
public:
    static std::shared_ptr<Application> getInstance();
    virtual ~Application();
public:
    void setBackgroundColor(const sf::Color &color);

    void installComponents();
    bool execute(std::shared_ptr<Node> object);

    void setWindow(std::shared_ptr<sf::RenderWindow> window);
    std::shared_ptr<sf::RenderWindow> getWindow()const;

    sf::Vector2f getMousePosition();

    void addExitCallback(std::function<void()> callback);
    void exit();
private:
    Application();
    std::unique_ptr<class ApplicationData> data;
};

#define GET_APPLICATION_COMPONENT(component) GET_COMPONENT(Application::getInstance(),component)
